package com.own.component.netty.controller;

import com.alibaba.fastjson2.JSON;
import com.own.component.netty.constant.ConstantCommon;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * HelloController
 *
 * @author chenxueli
 * @date 2021/4/9 15:18
 */
@RestController
@RequestMapping(ConstantCommon.WEBSOCKET)
public class HelloController {

    @GetMapping("hello1")
    public String hello1() {
        return "helloWorld";
    }

    @GetMapping("hello2")
    public void hello2() {
        System.err.println("执行了hello2");
    }

    @GetMapping("hello3")
    public void hello3(@RequestParam String test) {
        System.err.println("执行了hello3 + " + test);
    }

    @GetMapping("hello4")
    public String hello3(String test, String aaa) {
        System.err.println("执行了hello3 + " + test);
        return aaa;
    }

    @GetMapping("hello5")
    public Map<String, Object> hello5(String test, String aaa) {
        var map = new HashMap<String, Object>(8);
        map.put("key", aaa);
        map.put("test", test);
        return map;
    }

    @GetMapping("hello6")
    public TestModel hello6(TestModel model) {
        System.out.println(JSON.toJSONString(model));
        return model;
    }

}
